package com.rocketmq.listener;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author 派大星
 * @Description TODO
 * @Date 2025/7/31 16:45
 */
@Component
@RocketMQMessageListener(topic = "bootTagTopic",
        consumerGroup = "boot-tag-consumer-group",
        selectorType = SelectorType.TAG,
        selectorExpression = "tagB"
//        selectorType = SelectorType.SQL92, // sql92过滤模式
//        // selectorType=SelectorType.TAG，指定使用tag过滤。（也可以使用sql92需要在配置文件broker.conf中开启 enbalePropertyFilter=true)
//        selectorExpression = "a in (1,2,3)"
)
public class CTagAMsgListener implements RocketMQListener<MessageExt> {

    @Override
    public void onMessage(MessageExt messageExt) {
        System.out.println("我可以接受TagA和TagB的消息: " + new String(messageExt.getBody()));
    }
}
